<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('发送每日数据')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<style>
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }

</style>
<body>
<div class="ui-layout-center">
    <form id="region-form">
        <input type="hidden" name="CREDITNAME" id="CREDITNAME" value="zzz">
        <input type="hidden" name="hxqyName" id="hxqyName" value="zzz">

        <input type="hidden" name="CREDIT_NAME" id="CREDIT_NAME" value="zzz">
        <input type="hidden" name="CREDIT_CODE" id="CREDIT_CODE" value="zzz">
        <input type="hidden" name="hxqyCode" id="hxqyCode" value="zzz">

        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 select-table table-striped">
                    <h4 class="form-header h4">供应商列表</h4>
                    <table id="credit"></table>
                </div>

                <div class="col-sm-12 select-table table-striped">
                    <h4 class="form-header h4">接受账款存量数据</h4>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="accountsPush()">推送至中征平台</a>
                    <table id="stockDataAccounts"></table>
                </div>

                <div class="col-sm-12 select-table table-striped">
                    <h4 class="form-header h4">接受付款信息存量数据</h4>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="paymentPush()">推送至中征平台</a>
                    <table id="stockDataPayment"></table>
                </div>

                <div class="col-sm-12 select-table table-striped">
                    <h4 class="form-header h4">接受供应商回款账户</h4>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="supplierPush()">推送至中征平台</a>
                    <table id="stockSupplierAccount"></table>
                </div>

                <div class="col-sm-12 select-table table-striped">
                    <h4 class="form-header h4">调账数据</label></h4>
                    <a class="btn btn-primary btn-rounded btn-sm" onclick="reconciliationPush()">推送至中征平台</a>
                    <table id="reconciliationData"></table>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
    var prefix = ctx + 'middlesignDay';
    var prefix1 = ctx + 'middlesignSan';

    $(function () {
        var credit = {
            url: prefix + '/getMiddlesCreditDayList',
            id: "credit",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'creditCode',
                    title: '供应商统一社会信用代码'
                },
                {
                    field: 'CREDITNAME',
                    title: '供应商名称'
                },
                {
                    field: 'hxqyName',
                    title: '核心企业名称'
                },
                {
                    field: 'hxqyCode',
                    title: '核心企业统一社会信用代码'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="findDayData(\'' + row.CREDITNAME + '\',\'' + row.creditCode + '\',\'' + row.hxqyName + '\',\'' + row.hxqyCode + '\')"><i class="fa fa-edit"></i>查看当天数据</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(credit);


        var stockDataAccounts = {
            url: prefix + '/findStockDataAccounts',
            id: "stockDataAccounts",
            modalName: "接受账款存量数据",
            height: 600,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'ID',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'CREDIT_CODE',
                    title: '供应商统一社会信用代码*'
                },
                {
                    field: 'CREDIT_NAME',
                    title: '供应商名称*'
                },
                {
                    field: 'COMPANY_CODE',
                    title: '具体债务公司机构信用代码'
                },
                {
                    field: 'ORDER_CODE',
                    title: '应付账款凭证号*'
                },
                {
                    field: 'ORDER_AMT',
                    title: '应付账款凭证金额*'
                },
                {
                    field: 'ORDER_START_DATE',
                    title: '挂账日期*'
                },
                {
                    field: 'ORDER_END_DATE',
                    title: '应付账款到期日*'
                },
                {
                    field: 'Voucher_No',
                    title: 'zzz',
                    visible: false
                },
                {
                    field: 'INVOICE_NO',
                    title: '发票号*'
                },
                {
                    field: 'ORDER_NO',
                    title: '订单号'
                },
                {
                    field: 'CONTRACT_NO',
                    title: '合同号*'
                },
                {
                    field: 'ORDER_CURCD',
                    title: '币别*'
                },
                {
                    field: 'ORDER_YEAR',
                    title: '年份*'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.modal.open(\'' + "修改接受账款存量数据" + '\',\'' + ctx + "middlesignSan/editDataAccounts/" + row.ID + "?table=ZZ_Accounts_Day" + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(stockDataAccounts);


        var stockDataPayment = {
            url: prefix + '/findStockDataPayment',
            id: "stockDataPayment",
            updateUrl: prefix + "/editDataPayment/{id}",
            modalName: "接受付款信息存量数据",
            height: 600,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'ID',
                    title: 'ID'
                },
                {
                    field: 'CREDIT_CODE',
                    title: '供应商统一社会信用代码*'
                },
                {
                    field: 'CREDIT_NAME',
                    title: '供应商名称*'
                },
                {
                    field: 'PAY_CODE',
                    title: '付款凭证号*'
                },
                {
                    field: 'PAY_CURCD',
                    title: '币别*'
                },
                {
                    field: 'PAY_AMT',
                    title: '付款金额*'
                },
                {
                    field: 'PAY_DATE',
                    title: '付款日期*'
                },
                {
                    field: 'Voucher_No',
                    title: 'zzz',
                    visible: false
                },
                {
                    field: 'PAY_YEAR',
                    title: '会计年份*'
                },
                {
                    field: 'COMPANY_CODE',
                    title: '具体债务公司机构信用代码'
                },
                {
                    field: 'ORDER_CODE',
                    title: '应付账款凭证号*'
                },
                {
                    field: 'MARK1',
                    title: '账款被支付金额'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.modal.open(\'' + "修改接受付款信息存量数据" + '\',\'' + ctx + "middlesignSan/editDataPayment/" + row.ID + "?table=ZZ_Payment_Day" + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(stockDataPayment);

        var stockSupplierAccount = {
            url: prefix + '/findStockSupplierAccount',
            id: "stockSupplierAccount",
            updateUrl: prefix + "/editDataSupplierAccount/{id}",
            modalName: "接受供应商回款账户数据",
            height: 600,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'COMPANY_NAME',
                    title: '核心企业名称'
                },
                {
                    field: 'COMPANY_CODE',
                    title: '核心企业统一社会信用代码'
                },
                {
                    field: 'CREDIT_NAME',
                    title: '供应商名称'
                },
                {
                    field: 'CREDIT_CODE',
                    title: '供应商统一社会信用代码'
                },
                {
                    field: 'BACK_ACCOUNT_NAME',
                    title: '回款账户户名'
                },
                {
                    field: 'BACK_ACCOUNT_NO',
                    title: '回款账号'
                },
                {
                    field: 'OPEN_BANK_NAME',
                    title: '开户行'
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.modal.open(\'' + "修改供应商回款账户数据" + '\',\'' + ctx + 'middlesignSan' + "/editDataSupplierAccount/" + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(stockSupplierAccount);


        var reconciliationData = {
            url: prefix + '/findReconciliationData',
            id: "reconciliationData",
            modalName: "调账数据",
            height: 600,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'CREDIT_CODE',
                    title: '供应商统一社会信用代码'
                },
                {
                    field: 'CREDIT_NAME',
                    title: '供应商名称'
                },
                {
                    field: 'ACCOUNT_ADJUSTMENT_NO',
                    title: '被调账凭证号'
                },
                {
                    field: 'ACCOUNT_ADJUSTMENT_DATE',
                    title: '调账日期'
                },
                {
                    field: 'ACCOUNT_ADJUSTMENT_AMT',
                    title: '调账金额'
                },
                {
                    field: 'CURCD',
                    title: '币种'
                },
                {
                    field: 'ADJUSTMENT_DIRECTION',
                    title: '调账方向'
                },
                {
                    field: 'MARK1',
                    title: '备注'
                },
                {
                    field: 'MARK2',
                    title: '会计年份'
                },
                {
                    field: 'MARK3',
                    title: '调账凭证号'
                },
                {
                    field: 'Voucher_No',
                    title: 'zzz',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.modal.open(\'' + "修改调账数据" + '\',\'' + ctx + "middlesignSan/editReconciliation/" + row.ID + "?table=ZZ_Reconciliation_Day" + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(reconciliationData);
    })


    function findDayData(CREDIT_NAME,CREDIT_CODE,hxqyName,hxqyCode) {
        $("#CREDITNAME").val(CREDIT_NAME);
        $("#CREDIT_NAME").val(CREDIT_NAME);
        $("#CREDIT_CODE").val(CREDIT_CODE);
        $("#hxqyName").val(hxqyName);
        $("#hxqyCode").val(hxqyCode);

        $("#stockDataAccounts").bootstrapTable('refresh');
        $("#stockDataPayment").bootstrapTable('refresh');
        $("#stockSupplierAccount").bootstrapTable('refresh');
        $("#reconciliationData").bootstrapTable('refresh');
    }


    function accountsPush() {
        var CREDIT_NAME = $("#CREDIT_NAME").val();
        var CREDIT_CODE = $("#CREDIT_CODE").val();
        var hxqyName = $("#hxqyName").val();
        var hxqyCode = $("#hxqyCode").val();

        var data = $("#stockDataAccounts").bootstrapTable('getData');
        $.ajax({
            type: "POST",
            url: prefix1 + '/accountsPushData?type=day',
            data: {'data': JSON.stringify(data), "CREDIT_NAME": CREDIT_NAME,"CREDIT_CODE": CREDIT_CODE, "hxqyName": hxqyName,"hxqyCode": hxqyCode},
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    alert("推送成功");
                } else {
                    alert("推送错误:" + data.data);
                }
            }
        })
    }

    function paymentPush() {
        var CREDIT_NAME = $("#CREDIT_NAME").val();
        var CREDIT_CODE = $("#CREDIT_CODE").val();
        var hxqyName = $("#hxqyName").val();
        var hxqyCode = $("#hxqyCode").val();

        var data = $("#stockDataPayment").bootstrapTable('getData');
        $.ajax({
            type: "POST",
            url: prefix1 + '/paymentPushData?type=day',
            data: {'data': JSON.stringify(data) , "CREDIT_NAME": CREDIT_NAME,"CREDIT_CODE": CREDIT_CODE, "hxqyName": hxqyName,"hxqyCode": hxqyCode},
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    alert("推送成功");
                } else {
                    console.log(data);
                    alert("推送错误:" + data.data);
                }
            }
        })
    }

    function supplierPush(){
        var CREDIT_NAME = $("#CREDIT_NAME").val();
        var CREDIT_CODE = $("#CREDIT_CODE").val();
        var hxqyName = $("#hxqyName").val();
        var hxqyCode = $("#hxqyCode").val();

        var data = $("#stockSupplierAccount").bootstrapTable('getData');
        $.ajax({
            type: "POST",
            url: prefix1 + '/supplierPush?type=day',
            data: {'data': JSON.stringify(data), "CREDIT_NAME": CREDIT_NAME,"CREDIT_CODE": CREDIT_CODE, "hxqyName": hxqyName,"hxqyCode": hxqyCode},
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    alert("推送成功");
                } else {
                    alert("推送错误:" + data.data);
                }
            }
        })
    }

    function reconciliationPush(){
        var CREDIT_NAME = $("#CREDIT_NAME").val();
        var CREDIT_CODE = $("#CREDIT_CODE").val();
        var hxqyName = $("#hxqyName").val();
        var hxqyCode = $("#hxqyCode").val();

        var data = $("#reconciliationData").bootstrapTable('getData');
        $.ajax({
            type: "POST",
            url: prefix1 + '/reconciliationDataPush?type=day',
            data: {'data': JSON.stringify(data), "CREDIT_NAME": CREDIT_NAME,"CREDIT_CODE": CREDIT_CODE, "hxqyName": hxqyName,"hxqyCode": hxqyCode},
            dataType: 'json',
            success: function (data) {
                if (data.code == 0) {
                    alert("推送成功");
                } else {
                    alert("推送错误:" + data.data);
                }
            }
        })
    }

</script>
</body>
</html>